#include <iostream>
using namespace std;
#include <vector>
// 用与快速求出一段区间的子区间加减C,传统是O(n*m)
// 1.给出一段二维数组  2.我们得出它的差分(两个数的差值存在数组) 3.对要求的区间+-c 4.求其前缀和 5.打印出来
int n, m, q;
vector<vector<int>> a(n + 1, vector<int>(m + 1));
vector<vector<int>> s(n + 1, vector<int>(m + 1));
void insert(int x1,int y1,int x2,int y2,int c){
    s[x1][y1] += c;
    s[x2 + 1][y1] -= c;
    s[x1][y2 + 1] -= c;
    a[x2 + 1][y2 + 1] += c;
}
int main()
{

    cin >> n >> m >> q;

    auto s = a;

    // 1.读入数组
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j <= m;j++){
            scanf("%d", &a[i][j]);
        }
            
    }
    // 2.求其差分数组,原数组是这前缀和
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            insert(i, j, i, j, a[i][j]);
        }
    }

    // 3对要求的区间[l,r] +- c
    while(q--){
        int x1, y1, x2, y2, c;
        cin >> x1 >> y1 >> x2 >> y2 >> c;
        insert(x1, y1, x2, y2, c);
    }
    // 4.求差分数组的前缀和
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j <= m; j++)
        {
            s[i][j] += s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];
        }
    }

    // 5.打印
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j <= m; j++)
        {
            cout << a[i][j] << " ";
        }
    }

    return 0;
}
